package com.fcscs.cservice.dao;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.stereotype.Repository;

import com.fcscs.cservice.domain.Folio;
import com.fcscs.cservice.domain.Message;
import com.fcscs.cservice.domain.RC;
import com.fcscs.cservice.domain.ReservationBase;
import com.fcscs.cservice.domain.model.BillingView;
import com.fcscs.cservice.domain.model.BillingViewForFile;
import com.fcscs.cservice.domain.model.FolioView;
import com.fcscs.cservice.domain.model.FolioViewForFile;
import com.fcscs.cservice.domain.model.MessageView;
import com.fcscs.cservice.domain.model.RCView;
import com.fcscs.cservice.domain.model.RCViewForFile;
import com.fcscs.cservice.domain.model.RateView;
import com.fcscs.cservice.domain.model.RateViewForFile;
import com.fcscs.cservice.domain.model.ReservationView;

@Repository
public interface ReservationDao {
	/**
	 * find reservations (simple search)
	 * @param propId property id
	 * @param term term to search in first name, last name, confirmation no
	 * @param rsvStatusId reservation status id
	 * @param startTime start time
	 * @param endTime end time
	 * @param start 0 based start index
	 * @param resultCnt max result count limit
	 * @return
	 */
	List<ReservationView> findReservations(long propId, String term, Long rsvStatusId, Date startTime, Date endTime, int start, int resultCnt);

	/**
	 * total of find reservations result (simple search)
	 * @param propId propertyId
	 * @param term term to search in first name, last name, confirmation no
	 * @param rsvStatusId reservation status id
	 * @param startTime start time
	 * @param endTime end time
	 * @return
	 */
	int findReservationsCnt(long propId, String term, Long rsvStatusId, Date startTime, Date endTime);

	/**
	 * find reservations (advanced search)
	 * @param propId property id
	 * @param firstName guest first name
	 * @param lastName guest last name
	 * @param rsvStatus reservation status id
	 * @param roomNo room no
	 * @param memberNo membership no
	 * @param roomStatus room status id
	 * @param baggageNo baggage no
	 * @param arrivDate arrival date
	 * @param departDate departure date
	 * @param eta expected arrival time
	 * @param etd expected departure time
	 * @param date today
	 * @param start 0 based start index
	 * @param resultCnt max result count limit
	 * @return
	 */
	List<ReservationView> findReservations(long propId, String firstName, String lastName, Long rsvStatus, String roomNo, 
			String memberNo, Long roomStatus, String baggageNo, Date arrivDate, Date departDate, Date eta, Date etd,
			Date startTime, Date endTime, int start, int resultCnt);

	/**
	 * total of find reservations result (advanced search)
	 * @param propId property id
	 * @param firstName guest first name
	 * @param lastName guest last name
	 * @param rsvStatus reservation status id
	 * @param roomNo room no
	 * @param memberNo membership no
	 * @param roomStatus room status id
	 * @param baggageNo baggage no
	 * @param arrivDate arrival date
	 * @param departDate departure date
	 * @param eta expected arrival time
	 * @param etd expected departure time
	 * @param date today
	 * @return
	 */
	int findReservationsCnt(long propId, String firstName, String lastName, Long rsvStatus, String roomNo, String memberNo,
			Long roomStatus, String baggageNo, Date arrivDate, Date departDate, Date eta, Date etd, Date startTime, Date endTime);

	List<ReservationView> findRsvForFolio(long propId, String firstName, String lastName, Long rsvStatusId, String roomNo,
			Date arrivStart, Date arrivEnd, Date departStart, Date departEnd, Date date, int start, int resultCnt);

	int findRsvForFolioCnt(long propId, String firstName, String lastName, Long rsvStatusId, String roomNo,
			Date arrivStart, Date arrivEnd, Date departStart, Date departEnd, Date date);
	
	/**
	 * get ReservationView by id
	 * @param id
	 * @return
	 */
	ReservationView getReservationView(long id);

	/**
	 * get ReservationBase by id
	 * @param id
	 * @return
	 */
	ReservationBase getReservation(long id);

	/**
	 * update reservation content
	 * @param rsv reservation to be updated
	 * @return
	 */
	ReservationBase updateReservation(ReservationBase rsv);

	/**
	 * get RCView by id
	 * @param id
	 * @return
	 */
	RCView getRCView(long id);

	/**
	 * get RCView by id. this api is for pdf generation
	 * @param id
	 * @return
	 */
	RCViewForFile getRCViewForFile(long id);

	/**
	 * get latest RC of a reservation
	 * @param rsvId reservation id
	 * @param cls RC.class or RCWithGuest.class
	 * @return
	 */
	RC getRC(long id);

	/**
	 * get all RCs of multiple reservations
	 * @param rsvIds reservation ids
	 * @return
	 */
	public Map<Long, List<ReservationView.RC>> getRCs(Set<Long> rsvIds);
	
	/**
	 * update rc content
	 * @param rc rc to be updated
	 * @return
	 */
	RC updateRC(RC rc);
	
	/**
	 * get folio by id
	 * @param id
	 * @return
	 */
	FolioView getFolioView(long id);
	
	/**
	 * get folio by id
	 * @param id
	 * @return
	 */
	FolioViewForFile getFolioViewForFile(long id);

	/**
	 * get folio by id
	 * @param id
	 * @return
	 */
	Folio getFolio(long id);

	/**
	 * get billing records of a folio
	 * @param folioId folio id
	 * @return
	 */
	List<BillingView> getBillings(long folioId);

	/**
	 * get billing records of a folio
	 * @param folioId folio id
	 * @return
	 */
	List<BillingViewForFile> getBillingsForFile(long folioId);

	/**
	 * get all messages of a reservation
	 * @param rsvId reservation id
	 * @return
	 */
	List<MessageView> getMessages(long rsvId);

	/**
	 * update message isRead status
	 * @param messageList
	 * @return
	 */
	List<Message> updateMessages(List<Message> msgList);

//	/**
//	 * process an express check in
//	 * @param rsvId reservation id
//	 * @param rc rc with guest signature
//	 * @return
//	 */
//	boolean expressCheckIn(long rsvId, RCView rc);
//
//	/**
//	 * process check out
//	 * @param rsvId reservation id
//	 * @param folio folio with guest signature
//	 * @param isAuto true: auto check out; false: manual check out
//	 * @return
//	 */
//	boolean checkOut(long rsvId, FolioView folio, boolean isAuto);
//
//	/**
//	 * send a copy of folio after successfully auto checked out
//	 * @param rsvId reservation id
//	 * @param folioId folio id
//	 * @return
//	 */
//	boolean sendEFolio(long rsvId, long folioId);

	/**
	 * get rate list by rc id
	 * @param rcId
	 * @return
	 */
	List<RateView> getRateViews(long rcId);

	/**
	 * get rate list by rc id
	 * @param rcId
	 * @return
	 */
	List<RateViewForFile> getRateViewsForFile(long rcId);

	Folio updateFolio(Folio folio);

	List<Message> getMessages(Set<Long> msgIds);

	ReservationView getCurReservationViewByGP(long gpId);
	
}
